//
//  MyDocument.h
//  iMed
//
//  Created by Barry Press on 8/14/09.
//  Copyright Barry Press 2009 . All rights reserved.
//


#import <Foundation/Foundation.h>
#import "DataSet.h"

@interface MyDocument : NSDocument
{
	DataSet* dataset;
	NSTimer* timer;
	BOOL bTimerEnabled;
	NSSound* sAlarm;
	
	IBOutlet NSDatePicker* datePicker;
	IBOutlet NSDatePicker* nextTime;
	IBOutlet NSDatePicker* nowTime;
	IBOutlet NSButton* enableButton;
	IBOutlet NSView* mainView;
	
	IBOutlet NSTableView* rxList;
	IBOutlet NSTableView* historyList;
	IBOutlet NSTableView* ndcList;
	IBOutlet NSTableView* rxeList;
	IBOutlet NSArrayController* hController;
	IBOutlet NSArrayController* rxController;
	IBOutlet NSArrayController* ndcController;
	IBOutlet NSArrayController* rxeController;
	
	// ===========================================
	
	IBOutlet NSWindow* myCustomSheet;
	IBOutlet NSTextView* csText;
}

- (IBAction)pushCreateHistoryButton:(id)sender;
- (IBAction)pushCreateNDCButton:(id)sender;
- (IBAction)pushCreateRXButton:(id)sender;
- (IBAction)pushUpdateButton:(id)sender;
- (IBAction)pushEnableButton:(id)sender;
- (IBAction)pushAtDateButton:(id)sender;
- (IBAction)pushAutoButton:(id)sender;
- (IBAction)menuPreload:(id)sender;
- (IBAction)pushStopButton:(id)sender;
- (IBAction)pushForecastButton:(id)sender;


- (void)preloadRX;
- (void)preloadNDC;

- (void)processHistoryCreationAtTime:(NSDate*)aTime;
- (void)updateForecastForRX:(RX*)anRx;
- (void)updateForecast; 


- (NDCitem*)findSelectedNDCEntry;
- (NSArray*)findSelectedRXEntries;

- (void)timerFireMethod:(NSTimer*)theTimer;

- (NSPrintOperation*)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError;
- (void)printForecastToView:(NSView*)v;
- (void)printForecastToView:(NSView*)v;
- (void)showCustomSheet: (NSWindow *)window;
- (IBAction)closeMyCustomSheet: (id)sender;- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;

- (BOOL)keepBackupFile;
- (NSWindow*)myWindow;
- (void)setEditedStatus;
- (void)setEditedStateToBe:(BOOL)state;


///- (NSArrayController*)rxeController;
@property (readwrite, retain) DataSet* dataset;
@property (readonly) NSArrayController* rxeController;
@property (readonly) NSArrayController* ndcController;
@property (readonly) NSArrayController* rxController;


@end
